package com.haitaoit.chengquan.module.center.activity.yuyue;

import android.app.Dialog;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.haitaoit.chengquan.R;
import com.haitaoit.chengquan.base.BackCall;
import com.haitaoit.chengquan.base.BaseActivity;
import com.haitaoit.chengquan.module.center.adapter.yuyue.MyYuyueAdapter;
import com.haitaoit.chengquan.module.center.model.MyYuyueModel;
import com.haitaoit.chengquan.module.home.activity.maintenance.ServerPayActivity;
import com.haitaoit.chengquan.utils.Constant;
import com.haitaoit.chengquan.utils.DateTimeUtil;
import com.haitaoit.chengquan.utils.DialogUtil;
import com.haitaoit.chengquan.utils.GetSign;
import com.haitaoit.chengquan.utils.HttpUtilsSingle;
import com.haitaoit.chengquan.utils.NameValuePairSign;
import com.haitaoit.chengquan.utils.PreferenceUtils;
import com.haitaoit.chengquan.utils.ToastUtils;
import com.haitaoit.chengquan.view.MyListView;
import com.haitaoit.chengquan.view.PullToRefreshBase;
import com.haitaoit.chengquan.view.PullToRefreshScrollView;
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.exception.HttpException;
import com.lidroid.xutils.http.RequestParams;
import com.lidroid.xutils.http.ResponseInfo;
import com.lidroid.xutils.http.callback.RequestCallBack;
import com.lidroid.xutils.view.annotation.ViewInject;
import com.lidroid.xutils.view.annotation.event.OnClick;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

public class MyYuyueActivity extends BaseActivity implements PullToRefreshBase.OnRefreshListener<ScrollView> {
    @ViewInject(R.id.pull_to_refresh_scrollview)
    PullToRefreshScrollView pullrefreshscrollview;
    @ViewInject(R.id.yuyue_all)
    TextView                yuyue_all;
    @ViewInject(R.id.yuyue_nopay)
    TextView                yuyue_nopay;
    @ViewInject(R.id.yuyue_already_pay)
    TextView                yuyue_already_pay;
    @ViewInject(R.id.yuyue_finish)
    TextView                yuyue_finish;
    @ViewInject(R.id.yuyue_already_eva)
    TextView                yuyue_already_eva;
    @ViewInject(R.id.yuyue_line1)
    View                    yuyue_line1;
    @ViewInject(R.id.yuyue_line2)
    View                    yuyue_line2;
    @ViewInject(R.id.yuyue_line3)
    View                    yuyue_line3;
    @ViewInject(R.id.yuyue_line4)
    View                    yuyue_line4;
    @ViewInject(R.id.yuyue_line5)
    View                    yuyue_line5;
    @ViewInject(R.id.yuyue_line6)
    View                    yuyue_line6;
    @ViewInject(R.id.all_count)
    TextView                all_count;
    @ViewInject(R.id.not_pay_count)
    TextView                not_pay_count;
    @ViewInject(R.id.have_pay_count)
    TextView                have_pay_count;
    @ViewInject(R.id.completed_count)
    TextView                completed_count;
    @ViewInject(R.id.evaluation_count)
    TextView                evaluation_count;
    @ViewInject(R.id.jichuang_last)
    TextView                jichuang_last;
    @ViewInject(R.id.jichuang_last_text)
    TextView                jichuang_last_text;
    @ViewInject(R.id.jichuang_last_relayla)
    RelativeLayout          jichuang_last_relayla;

    private LinearLayout null_information_layout;
    private MyListView   listView;
    private ScrollView   mScrollView;
    private EditText     search_et;

    private boolean isFrist    = true;
    private int     page       = 1;
    private String  order_type = "all", title_type = "1";

    private MyYuyueAdapter adapter;
    private Dialog         dlg;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_yuyue);
        ViewUtils.inject(this);


        View view = LayoutInflater.from(this).inflate(R.layout.scrollview_listview_layout2, null);
        findViewById(R.id.search_LL).setVisibility(View.VISIBLE);
        null_information_layout = (LinearLayout) view.findViewById(R.id.null_information_layout);
        listView = (MyListView) view.findViewById(R.id.scrollview_listview);
        search_et = (EditText) findViewById(R.id.search_et);
        search_et.setHint("请输入搜索内容...");
        findViewById(R.id.search_img).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (search_et.getText().toString().equals("")) {
                    ToastUtils.showToast("输入搜索内容！");
                } else {
                    isFrist = true;
                    page = 1;
                    if (title_type.equals("1")) {
                        httpGetuser_service_list(Constant.Getuser_service_list);
                    } else {
                        httpGetuser_service_list(Constant.Getuser_service_jcgz_list);
                    }
                }
            }
        });

        pullrefreshscrollview.setPullLoadEnabled(true);
        pullrefreshscrollview.setPullRefreshEnabled(true);
        pullrefreshscrollview.setOnRefreshListener(this);
        pullrefreshscrollview.setLastUpdatedLabel(DateTimeUtil
                .getFormatDateTime(DateTimeUtil.getCurrTimestamp()));
        mScrollView = pullrefreshscrollview.getRefreshableView();
        mScrollView.setFillViewport(true);
        mScrollView.setVerticalScrollBarEnabled(false);
        mScrollView.addView(view);

        adapter = new MyYuyueAdapter(this);
        adapter.setTitle_type(title_type);
        adapter.setBackCall(backCall);
        listView.setAdapter(adapter);

        //初始化
        jichuang_last_relayla.setVisibility(View.GONE);
        yuyue_line6.setVisibility(View.GONE);
    }

    @Override
    protected void onResume() {
        isFrist = true;

        page = 1;
        if (title_type.equals("1")) {
            httpGetuser_service_list(Constant.Getuser_service_list);
        } else {
            httpGetuser_service_list(Constant.Getuser_service_jcgz_list);
        }
        super.onResume();
    }

    @OnClick({R.id.left, R.id.yuyue_rb1, R.id.yuyue_rb2, R.id.yuyue_all, R.id.yuyue_nopay,
            R.id.yuyue_already_pay, R.id.yuyue_finish, R.id.yuyue_already_eva,R.id.jichuang_last})
    public void onClick(View v) {
        String string = search_et.getText().toString();
        switch (v.getId()) {

            case R.id.left:
                finish();
                break;
            case R.id.yuyue_rb1:// 机床维修
                title_type = "1";
                yuyue_nopay.setText("未支付");
                yuyue_already_pay.setText("已支付");
                yuyue_finish.setText("已完成");
                yuyue_already_eva.setText("已评价");
                jichuang_last_relayla.setVisibility(View.GONE);
                yuyue_line6.setVisibility(View.GONE);
                selectUrl();
                break;
            case R.id.yuyue_rb2:// 机床改造
                title_type = "2";
                yuyue_nopay.setText("已下单");
                yuyue_already_pay.setText("已确认");
                yuyue_finish.setText("已支付");
                yuyue_already_eva.setText("已完成");
                jichuang_last_relayla.setVisibility(View.VISIBLE);
                yuyue_line6.setVisibility(View.INVISIBLE);
                selectUrl();
                break;
            case R.id.yuyue_all:// 全部
                setColor();
                yuyue_all.setTextColor(getResources().getColor(R.color.app_color));
                yuyue_line1.setVisibility(View.VISIBLE);
                order_type = "all";
                selectUrl();
                break;
            case R.id.yuyue_nopay:// 未支付
                setColor();
                yuyue_nopay.setTextColor(getResources().getColor(R.color.app_color));
                yuyue_line2.setVisibility(View.VISIBLE);
                order_type = "nopay";
                selectUrl();
                break;
            case R.id.yuyue_already_pay:// 已支付
                setColor();
                yuyue_already_pay.setTextColor(getResources().getColor(R.color.app_color));
                yuyue_line3.setVisibility(View.VISIBLE);
                order_type = "already_pay";
                selectUrl();
                break;
            case R.id.yuyue_finish:// 已完成
                setColor();
                yuyue_finish.setTextColor(getResources().getColor(R.color.app_color));
                yuyue_line4.setVisibility(View.VISIBLE);
                order_type = "finish";
                selectUrl();
                break;
            case R.id.yuyue_already_eva:// 已评价
                setColor();
                yuyue_already_eva.setTextColor(getResources().getColor(R.color.app_color));
                yuyue_line5.setVisibility(View.VISIBLE);
                order_type = "already_eva";
                selectUrl();
                break;
            case R.id.jichuang_last:// (机床改造)已评价
                setColor();
                jichuang_last.setTextColor(getResources().getColor(R.color.app_color));
                yuyue_line6.setVisibility(View.VISIBLE);
                order_type = "already_last";
                selectUrl();
                break;
        }
    }

    public void selectUrl() {
        isFrist = true;
        page = 1;
        adapter.setTitle_type(title_type);
        if (title_type.equals("1")) {
            httpGetuser_service_list(Constant.Getuser_service_list);
        } else {
            httpGetuser_service_list(Constant.Getuser_service_jcgz_list);
        }
    }

    BackCall backCall = new BackCall() {
        @Override
        public void deal(int which, Object... obj) {
            final int position = (Integer) obj[0];
            Intent intent = new Intent();
            switch (which) {
                case R.id.yuyue_itemll:// 详情
                    //                case R.id.scrollview_listview:
                    intent.setClass(MyYuyueActivity.this, MyYuyueDetailActivity.class);
                    intent.putExtra("title_type", title_type);
                    intent.putExtra("order_no", adapter.getList().get(position).getOrder_no());
                    startActivity(intent);
                    break;
                case R.id.cancel_yuyue:// 取消订单
                    dlg = DialogUtil.showInfoDialog1(MyYuyueActivity.this, "提示",
                            "您确定要取消该预约订单吗？", "确定取消", "再想想", new BackCall() {
                                public void deal(int which, Object... obj) {
                                    switch (which) {
                                        case R.id.confirm:// 确定
                                            httpGetcancel_order(adapter.getList().get(position).getOrder_no());
                                            break;
                                    }
                                    super.deal(which);
                                }
                            });
                    dlg.setCanceledOnTouchOutside(true);
                    dlg.show();
                    break;
                case R.id.go_pay:// 付款
                    intent.setClass(MyYuyueActivity.this, ServerPayActivity.class);
                    intent.putExtra("order_no", adapter.getList().get(position).getOrder_no());
                    intent.putExtra("order_amount", adapter.getList().get(position).getMoney());
                    startActivity(intent);
                    break;
                case R.id.confirm_complete:// 确认完成
                    dlg = DialogUtil.showInfoDialog1(MyYuyueActivity.this, "提示",
                            "您确定该预约订单已完成吗？", "确定", "还没有", new BackCall() {
                                public void deal(int which, Object... obj) {
                                    switch (which) {
                                        case R.id.confirm:// 确定
                                            httpGetservice_complete_order(adapter.getList().get(position).getOrder_no());
                                            break;
                                    }
                                    super.deal(which);
                                }
                            });
                    dlg.setCanceledOnTouchOutside(true);
                    dlg.show();
                    break;
                case R.id.go_eva:// 去评价
                    intent.setClass(MyYuyueActivity.this, YuyueEvaluateActivity.class);
                    intent.putExtra("order_no", adapter.getList().get(position).getOrder_no());
                    intent.putExtra("type", "1");
                    intent.putExtra("myimage_uri", adapter.getList().get(position).getTitile_img());
                    startActivity(intent);
                    break;
                case R.id.detele_yuyue:// 删除订单
                    dlg = DialogUtil.showInfoDialog1(MyYuyueActivity.this, "提示",
                            "您确定要删除该预约订单吗？", "确定", "取消", new BackCall() {
                                public void deal(int which, Object... obj) {
                                    switch (which) {
                                        case R.id.confirm:// 确定
                                            httpGetdel_order(adapter.getList().get(position).getOrder_no());
                                            break;
                                    }
                                    super.deal(which);
                                }
                            });
                    dlg.setCanceledOnTouchOutside(true);
                    dlg.show();
                    break;
            }
            super.deal(which, obj);
        }
    };

    // 列表
    private void httpGetuser_service_list(String url) {
        int status = 0;// 分类0全部1未支付2已支付3已完成4已评价
        if ("all".equals(order_type)) {
            status = 0;
        } else if ("nopay".equals(order_type)) {
            status = 1;
        } else if ("already_pay".equals(order_type)) {
            status = 2;
        } else if ("finish".equals(order_type)) {
            status = 3;
        } else if ("already_eva".equals(order_type)) {
            status = 4;
        }else if ("already_last".equals(order_type)) {
            status = 5;
        }

        List<NameValuePairSign> list = new ArrayList<NameValuePairSign>();
        list.add(new NameValuePairSign("user_id", PreferenceUtils.getPrefString("user_id", "")));
        list.add(new NameValuePairSign("status", status + ""));
        list.add(new NameValuePairSign("name", search_et.getText().toString()));
        list.add(new NameValuePairSign("page", page + ""));
        list.add(new NameValuePairSign("pagesize", Constant.PageSize));
        String sign = GetSign.genPackageSign(list);

        RequestParams params = new RequestParams();
        params.addQueryStringParameter("user_id", PreferenceUtils.getPrefString("user_id", ""));
        params.addQueryStringParameter("status", status + "");
        params.addQueryStringParameter("name", search_et.getText().toString());
        params.addQueryStringParameter("page", page + "");
        params.addQueryStringParameter("pagesize", Constant.PageSize);
        params.addQueryStringParameter("sign", sign);

        HttpUtilsSingle.doGet(this, false, url, params, new RequestCallBack<String>() {
            @Override
            public void onSuccess(ResponseInfo<String> arg0) {
                String result = arg0.result.toString();
                List<MyYuyueModel> new_list = new ArrayList<MyYuyueModel>();
                try {
                    JSONObject json = new JSONObject(result);
                    String Errcode = json.getString("ErrCode");
                    String Errmsg = json.getString("ErrMsg");
                    String Response = json.getString("Response");
                    Gson gson = new Gson();
                    switch (Integer.valueOf(Errcode)) {
                        case 1:// 失败
                            ToastUtils.showToast(Errmsg);
                            pullrefreshscrollview.onPullDownRefreshComplete();
                            pullrefreshscrollview.onPullUpRefreshComplete();
                            new_list = new ArrayList<MyYuyueModel>();
                            break;
                        case 0:// 成功
                            JSONObject js = new JSONObject(Response);
                            System.out.println(js);
                            System.out.println(js);
                            System.out.println(js);
                            if (title_type.equals("1")) {
                                all_count.setText(js.getString("all_count"));
                                not_pay_count.setText(js.getString("not_pay_count"));
                                have_pay_count.setText(js.getString("have_pay_count"));
                                completed_count.setText(js.getString("completed_count"));
                                evaluation_count.setText(js.getString("evaluation_count"));
                            } else if (title_type.equals("2")) {
                                all_count.setText(js.getString("all_count"));
                                not_pay_count.setText(js.getString("not_pay_count"));
                                have_pay_count.setText(js.getString("confirm_count"));
                                completed_count.setText(js.getString("have_pay_count"));
                                evaluation_count.setText(js.getString("completed_count"));
                                jichuang_last_text.setText(js.getString("evaluation_count"));
                            }

                            if (all_count.getText().toString().equals("0")) {
                                all_count.setVisibility(View.GONE);
                            } else {
                                all_count.setVisibility(View.VISIBLE);
                            }
                            if (not_pay_count.getText().toString().equals("0")) {
                                not_pay_count.setVisibility(View.GONE);
                            } else {
                                not_pay_count.setVisibility(View.VISIBLE);
                            }
                            if (have_pay_count.getText().toString().equals("0")) {
                                have_pay_count.setVisibility(View.GONE);
                            } else {
                                have_pay_count.setVisibility(View.VISIBLE);
                            }
                            if (completed_count.getText().toString().equals("0")) {
                                completed_count.setVisibility(View.GONE);
                            } else {
                                completed_count.setVisibility(View.VISIBLE);
                            }
                            if (evaluation_count.getText().toString().equals("0")) {
                                evaluation_count.setVisibility(View.GONE);
                            } else {
                                evaluation_count.setVisibility(View.VISIBLE);
                            }
                            if (jichuang_last_text.getText().toString().equals("0")){
                                jichuang_last_text.setVisibility(View.GONE);
                            } else {
                                jichuang_last_text.setVisibility(View.VISIBLE);
                            }

                            new_list = gson.fromJson(js.getString("list_dy"),
                                    new TypeToken<List<MyYuyueModel>>() {
                                    }.getType());
                            break;
                        case 2:// 暂无内容
                            pullrefreshscrollview.onPullDownRefreshComplete();
                            pullrefreshscrollview.onPullUpRefreshComplete();
                            new_list = new ArrayList<MyYuyueModel>();
                            break;
                    }
                    if (isFrist) {
                        if (isNullDate(new_list)) {
                            adapter.setList(new_list);
                            adapter.notifyDataSetChanged();
                        }
                        pullrefreshscrollview.onPullDownRefreshComplete();
                    } else {
                        List<MyYuyueModel> allList = adapter.getList();
                        allList.addAll(new_list);
                        adapter.setList(allList);
                        adapter.notifyDataSetChanged();
                        pullrefreshscrollview.onPullUpRefreshComplete();
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }

            @Override
            public void onFailure(HttpException arg0, String arg1) {
                ToastUtils.showToast("获取数据失败,请检查网络");
            }
        });
    }

    // 需求服务完成订单
    private void httpGetservice_complete_order(String order_no) {
        List<NameValuePairSign> list = new ArrayList<NameValuePairSign>();
        list.add(new NameValuePairSign("user_id", PreferenceUtils.getPrefString("user_id", "")));
        list.add(new NameValuePairSign("order_no", order_no));
        String sign = GetSign.genPackageSign(list);

        RequestParams params = new RequestParams();
        params.addQueryStringParameter("user_id", PreferenceUtils.getPrefString("user_id", ""));
        params.addQueryStringParameter("order_no", order_no);
        params.addQueryStringParameter("sign", sign);

        HttpUtilsSingle.doGet(this, false, Constant.Getservice_complete_order, params, new RequestCallBack<String>() {
            @Override
            public void onSuccess(ResponseInfo<String> arg0) {
                String jsonString = arg0.result.toString();
                JSONObject json;
                try {
                    json = new JSONObject(jsonString);
                    String Errcode = json.getString("ErrCode");
                    String Errmsg = json.getString("ErrMsg");
                    String Response = json.getString("Response");
                    switch (Integer.valueOf(Errcode)) {
                        case 1:// 失败
                            ToastUtils.showToast(Errmsg);
                            return;
                        case 0:// 成功
                            ToastUtils.showToast(Errmsg);
                            isFrist = true;
                            page = 1;
                            if (title_type.equals("1")) {
                                httpGetuser_service_list(Constant.Getuser_service_list);
                            } else {
                                httpGetuser_service_list(Constant.Getuser_service_jcgz_list);
                            }
                            return;
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }

            public void onFailure(HttpException arg0, String arg1) {
                ToastUtils.showToast("获取数据失败,请检查网络");
            }
        });
    }

    // 取消订单
    private void httpGetcancel_order(String order_no) {
        List<NameValuePairSign> list = new ArrayList<NameValuePairSign>();
        list.add(new NameValuePairSign("user_id", PreferenceUtils.getPrefString("user_id", "")));
        list.add(new NameValuePairSign("order_no", order_no));
        String sign = GetSign.genPackageSign(list);

        RequestParams params = new RequestParams();
        params.addQueryStringParameter("user_id", PreferenceUtils.getPrefString("user_id", ""));
        params.addQueryStringParameter("order_no", order_no);
        params.addQueryStringParameter("sign", sign);

        HttpUtilsSingle.doGet(this, false, Constant.Getcancel_order, params, new RequestCallBack<String>() {
            @Override
            public void onSuccess(ResponseInfo<String> arg0) {
                String jsonString = arg0.result.toString();
                JSONObject json;
                try {
                    json = new JSONObject(jsonString);
                    String Errcode = json.getString("ErrCode");
                    String Errmsg = json.getString("ErrMsg");
                    String Response = json.getString("Response");
                    switch (Integer.valueOf(Errcode)) {
                        case 1:// 失败
                            ToastUtils.showToast(Errmsg);
                            return;
                        case 0:// 成功
                            ToastUtils.showToast(Errmsg);
                            isFrist = true;
                            page = 1;
                            if (title_type.equals("1")) {
                                httpGetuser_service_list(Constant.Getuser_service_list);
                            } else {
                                httpGetuser_service_list(Constant.Getuser_service_jcgz_list);
                            }
                            return;
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }

            public void onFailure(HttpException arg0, String arg1) {
                ToastUtils.showToast("获取数据失败,请检查网络");
            }
        });
    }

    // 删除订单
    private void httpGetdel_order(String order_no) {
        List<NameValuePairSign> list = new ArrayList<NameValuePairSign>();
        list.add(new NameValuePairSign("user_id", PreferenceUtils.getPrefString("user_id", "")));
        list.add(new NameValuePairSign("order_no", order_no));
        String sign = GetSign.genPackageSign(list);

        RequestParams params = new RequestParams();
        params.addQueryStringParameter("user_id", PreferenceUtils.getPrefString("user_id", ""));
        params.addQueryStringParameter("order_no", order_no);
        params.addQueryStringParameter("sign", sign);

        HttpUtilsSingle.doGet(this, false, Constant.Getdel_order, params, new RequestCallBack<String>() {
            @Override
            public void onSuccess(ResponseInfo<String> arg0) {
                String jsonString = arg0.result.toString();
                JSONObject json;
                try {
                    json = new JSONObject(jsonString);
                    String Errcode = json.getString("ErrCode");
                    String Errmsg = json.getString("ErrMsg");
                    String Response = json.getString("Response");
                    switch (Integer.valueOf(Errcode)) {
                        case 1:// 失败
                            ToastUtils.showToast(Errmsg);
                            return;
                        case 0:// 成功
                            ToastUtils.showToast(Errmsg);
                            isFrist = true;
                            page = 1;
                            if (title_type.equals("1")) {
                                httpGetuser_service_list(Constant.Getuser_service_list);
                            } else {
                                httpGetuser_service_list(Constant.Getuser_service_jcgz_list);
                            }
                            return;
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }

            public void onFailure(HttpException arg0, String arg1) {
                ToastUtils.showToast("获取数据失败,请检查网络");
            }
        });
    }

    public void setColor() {
        yuyue_all.setTextColor(getResources().getColor(R.color.black_text));
        yuyue_nopay.setTextColor(getResources().getColor(R.color.black_text));
        yuyue_already_pay.setTextColor(getResources().getColor(R.color.black_text));
        yuyue_finish.setTextColor(getResources().getColor(R.color.black_text));
        yuyue_already_eva.setTextColor(getResources().getColor(R.color.black_text));
        jichuang_last.setTextColor(getResources().getColor(R.color.black_text));

        yuyue_line1.setVisibility(View.INVISIBLE);
        yuyue_line2.setVisibility(View.INVISIBLE);
        yuyue_line3.setVisibility(View.INVISIBLE);
        yuyue_line4.setVisibility(View.INVISIBLE);
        yuyue_line5.setVisibility(View.INVISIBLE);

        if (TextUtils.equals("1",title_type)){
            yuyue_line6.setVisibility(View.GONE);
        }else {
            yuyue_line6.setVisibility(View.INVISIBLE);
        }
    }

    /**
     * @tab 判断listview是否有值
     */
    private boolean isNullDate(List<MyYuyueModel> rewordList) {
        if (rewordList == null || rewordList.size() == 0) {
            null_information_layout.setVisibility(View.VISIBLE);
            listView.setVisibility(View.GONE);
            return false;
        } else {
            null_information_layout.setVisibility(View.GONE);
            listView.setVisibility(View.VISIBLE);
            return true;
        }
    }

    @Override
    public void onPullDownToRefresh(PullToRefreshBase<ScrollView> refreshView) {
        pullrefreshscrollview.setLastUpdatedLabel(DateTimeUtil
                .getFormatDateTime(DateTimeUtil.getCurrTimestamp()));
        isFrist = true;
        page = 1;
        if (title_type.equals("1")) {
            httpGetuser_service_list(Constant.Getuser_service_list);
        } else {
            httpGetuser_service_list(Constant.Getuser_service_jcgz_list);
        }
    }

    @Override
    public void onPullUpToRefresh(PullToRefreshBase<ScrollView> refreshView) {
        pullrefreshscrollview.setLastUpdatedLabel(DateTimeUtil
                .getFormatDateTime(DateTimeUtil.getCurrTimestamp()));
        isFrist = false;
        page++;
        if (title_type.equals("1")) {
            httpGetuser_service_list(Constant.Getuser_service_list);
        } else {
            httpGetuser_service_list(Constant.Getuser_service_jcgz_list);
        }
    }
}
